package com.managerConsummer.controller;

import com.managerConsummer.service.PowerServiceFeign;
import entity.Role;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 权限控制器
 * The type Power controller.
 *
 * @author tapoliuliyue
 * @date 2022/04/23
 */
@RestController
@RequestMapping("/power")
@CrossOrigin
public class PowerController {

    @Autowired
    private PowerServiceFeign powerServiceFeign;

    private Logger logger = Logger.getLogger(this.getClass());

    /**
     * Select all power string.
     *
     * @return the string
     */
    @RequestMapping("/selectAllPower")
    public String selectAllPower() {
        String s = powerServiceFeign.selectAllPower();
        logger.debug("PowerController selectAllPower result:" + s);
        return s;
    }

    /**
     * Select by self string.
     *
     * @return the string
     */
    @RequestMapping("/selectBySelf")
    public String selectBySelf() {
        String s = powerServiceFeign.selectBySelf();
        logger.debug("PowerController selectBySelf result:" + s);
        return s;
    }

    /**
     * Update pr string.
     *
     * @param role the role
     * @return the string
     */
    @RequestMapping("/updatePr")
    public String updatePr(@RequestBody Role role) {
        String s = powerServiceFeign.updatePr(role);
        logger.debug("PowerController updatePr result:" + s);
        return s;
    }

    /**
     * Query power list string.
     *
     * @return the string
     */
    @RequestMapping("/queryPowerList")
    public String queryPowerList() {
        String s = powerServiceFeign.queryPowerList();
        logger.debug("PowerController queryPowerList result:" + s);
        return s;
    }
}
